package com.lq.ecoldchain.ui.login

import com.lq.ecoldchain.base.CommonLoadingViewModel
import com.lq.ecoldchain.base.viewmodel.addLifecycle
import org.kodein.di.Kodein
import org.kodein.di.KodeinContext
import org.kodein.di.android.support.AndroidLifecycleScope
import org.kodein.di.generic.bind
import org.kodein.di.generic.instance
import org.kodein.di.generic.scoped
import org.kodein.di.generic.singleton

/*
*2018/12/21 0021  14:23
*function by lq
*/

const val LOGIN_MODULE_TAG = "LOGIN_MODULE_TAG"

val loginKodeinModule = Kodein.Module(LOGIN_MODULE_TAG) {

    bind<LoginViewModel>() with scoped(AndroidLifecycleScope).singleton {
        LoginViewModel(instance()).apply {
            addLifecycle(context)
        }
    }

    bind<LoginViewDelegate>() with scoped(AndroidLifecycleScope).singleton {
        LoginViewDelegate(
                viewModel = instance(),
                loadingViewModel = CommonLoadingViewModel.instance(context)
        )
    }
}